import { defHttp } from '/@/utils/http/axios'
import { Sensor, SensorFeatureBo, SensorFeatureData } from './model/sensor'
import { Page } from '/@/api/model/baseModel'
import { ErrorMessageMode } from '/#/axios'

enum Api {
  List = '/deviceManagement/device/list',
  Edit = '/deviceManagement/device',
  SensorDataTime = '/deviceManagement/device/getSensorDataTime/',
  Add = '/sensor/add',
  Dlete = '/sensor/delete/',
  StartRequestData = '/sensor/startRequestData/',
  StopRequestData = '/sensor/stopRequestData/',
  ListFeatureData = '/sensor/listFeatureData',
  GetSensorRawDataNow = '/sensor/getSensorRawDataNow',
}

/**
 * @description: 获取列表
 */
export function ListApi(mode: ErrorMessageMode = 'modal') {
  return defHttp.get<Array<Sensor>>(
    {
      url: Api.List,
    },
    {
      errorMessageMode: mode,
    },
  )
}
/**
 * @description: 修改
 */
export function EditApi(params: Sensor, mode: ErrorMessageMode = 'modal') {
  return defHttp.put<Array<Sensor>>(
    {
      url: Api.Edit,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}

/**
 * @description: 获取传感器数据时间
 */
export function DataTimeApi(deviceSN: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<string>(
    {
      url: Api.SensorDataTime + deviceSN,
    },
    {
      errorMessageMode: mode,
    },
  )
}
/**
 * @description: 新增
 */
export function AddApi(params: Sensor, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<Array<Sensor>>(
    {
      url: Api.Add,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}

/**
 * @description: 删除
 */
export function DeleteApi(params: string, mode: ErrorMessageMode = 'modal') {
  return defHttp.delete<Array<Sensor>>(
    {
      url: Api.Dlete,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}



/**
 * @description: 获取列表
 */
export function StartRequestDataApi(params: string, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<boolean>(
    {
      url: Api.StartRequestData,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}

/**
 * @description: 获取列表
 */
export function StopRequestDataApi(params: string, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<void>(
    {
      url: Api.StopRequestData,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}

/**
 * @description: 获取特征数据
 */
export function ListFeatureDataApi(params: SensorFeatureBo, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<Page<SensorFeatureData>>(
    {
      url: Api.ListFeatureData,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}

/**
 * @description: 获取特征数据
 */
export function GetSensorRawDataNowApi(params: SensorFeatureBo, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<Page<SensorFeatureData>>(
    {
      url: Api.GetSensorRawDataNow,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}
